import java.awt.DisplayMode;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;

import javax.swing.JFrame;


public class Screen {
	private GraphicsDevice vc;
	private JFrame window;
	public Screen(){
		GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
		vc=env.getDefaultScreenDevice();
	}
	public void setFullScreen(DisplayMode dm,JFrame window){
		window.setUndecorated(true);
		window.setResizable(false);
		this.window = window;
		vc.setFullScreenWindow(window);
		if(dm != null && vc.isDisplayChangeSupported()){
			try{
				vc.setDisplayMode(dm);
			} 
			catch(Exception ex){}
		}
		//window.createBufferStrategy(2);
	}
	public void restoreScreen(){
		Window w = vc.getFullScreenWindow();
		if(w!=null)
		{
			w.dispose();
		}
		vc.setFullScreenWindow(null);
	}
	public Graphics2D getGraphics()
	{
		return (Graphics2D)window.getBufferStrategy().getDrawGraphics();
	}
}
